<template>
  <div class="webchat_domain_list">
    <!--<div class="tip">-->
      <!--<span >{{$t('config.channel.webchatGlobalMessage')}}</span>-->
      <!--<span >{{$t('config.channel.intentionMessage')}}</span>-->
    <!--</div>-->
    <keep-alive>
      <component v-bind:is="currentView"
                 :ref="currentView"
                 :random="random"
                 @edit="edit"
                 @back="back"
                 :domainData="domainData"
                 ></component>
    </keep-alive>
  </div>
</template>
<script>
  import domainTable from './webDomainTable.vue'
  import domainUpdate from './webDomainUpdate.vue'
  export default{
    name: 'webDomainCust',
    data () {
      return {
        currentView: 'domainTable',
        domainData: {},
        random: 0
      }
    },
    methods: {
      edit (data) {
        if (data && data !== -1) {
          this.domainData = data
        } else {
          this.domainData = {}
        }
        this.currentView = 'domainUpdate'
        this.random = Math.random()
      },
      back () {
        this.currentView = 'domainTable'
        this.$nextTick(() => {
          this.random = Math.random()
        })
      }
    },
    components: {
      domainTable,
      domainUpdate
    }
  }
</script>
<style lang="stylus" scoped>
  @import "../../../../../../assets/common.styl"
  .tip
    font-size 12px
    padding 10px
    color $c-prompt
    background-color #f4f5f9
    border-bottom 1px solid #cccccc
</style>